<template>
  <div class="container">
    <div class="form-container">
      <el-form :model="loginForm">
        <h2 style="text-align: center">
          欢迎登录
          <span>{{ APP_NAME }}</span>
        </h2>
        <el-form-item prop="username">
          <el-input
            v-model="loginForm.username"
            placeholder="请输入用户名"
          ></el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input
            type="password"
            v-model="loginForm.password"
            placeholder="请输入密码"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="doLogin">登录</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script setup>
import router from '@/router'
import { ref } from 'vue'

const loginForm = ref({})

const APP_NAME = ref(import.meta.env.VITE_APP_NAME)

console.log(import.meta.env)
const doLogin = () => {
  router.push('/')
}
</script>

<style scoped>
.container {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-image: url('../assets/login-bg.jpg');
  background-repeat: no-repeat;
  background-size: cover;
}

.form-container {
  width: 300px;
  padding: 40px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  border-radius: 8px;
}
.form-container h2 {
  text-align: center;
  font-size: 16px;
  margin-bottom: 20px;
}
.form-container h2 span {
  font-size: 14px;
}
.form-container .el-form-item {
  margin-bottom: 20px;
}
.form-container .el-button {
  width: 100%;
}
</style>
